#ifndef PG_QUERY_H
#define PG_QUERY_H

//PostgreSQL database connection to perform asynchronous queries without result

#include <string>

#include "concurentqueue.h"
#include "pgresult.h"

namespace Porridge
{

class PGQuery;
typedef ConcurrentQueue<PGQuery*>  PGQueryQueue;

class PGQuery
{
    PGconn * m_connection;
    PGQueryQueue * m_queryQueue;
    std::string m_query;

private:
    PGQuery(const PGQuery&);
    PGQuery& operator= (const PGQuery&);

public:
    PGQuery(const std::string &connectionInfo, PGQueryQueue *queryQueue);
    ~PGQuery();
    void setQuery(const std::string & query) {m_query = query;}
    std::string lastQuery() const {return m_query;}
    void performQuery();
};

}//namespace Porridge

#endif // PG_QUERY_H
